<template>
  <div class="data-manage">
    <div class="topSearch">
      <el-form :inline="true" :model="searchInfo" class="demo-form-inline">
        <el-form-item class="s1" label="物种">
          <el-input v-model="searchInfo.user" placeholder="物种"></el-input>
        </el-form-item>
        <el-form-item class="s2" label="监测时间">
          <el-date-picker v-model="searchInfo.time" type="daterange" range-separator="-" start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item class="s1" label="体长">
          <el-input v-model="searchInfo.long" placeholder="体长"></el-input>
        </el-form-item>
        <el-form-item class="s1" label="体重">
          <el-input v-model="searchInfo.weight" placeholder="体重"></el-input>
        </el-form-item>

        <el-button type="primary" @click="reset">重置</el-button>
        <el-button type="primary" @click="onSubmit">查询</el-button>

      </el-form>
    </div>

    <div class="tab">
      <el-table ref="multipleTable" stripe :data="tableData" tooltip-effect="dark" style="width: 100% ; height: 90%;"
      @selection-change="handleSelectionChange"  >
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column label="序号" type="index">
          <!-- <template slot-scope="scope">{{ scope.row.date }}</template> -->
        </el-table-column>
        <el-table-column prop="speciesName" label="物种" >
        </el-table-column>
        <el-table-column prop="name"  label="图像" >
          <template slot-scope="scope">
            <div><img style="width: 80px; height: 80px;" src="../../../assets/bird.png" alt=""></div>
          </template>
        </el-table-column>
        <el-table-column prop="createdTime" label="监测时间" >
        </el-table-column>
        <el-table-column prop="weight" label="重量" >
        </el-table-column>
        <el-table-column prop="bodyLength" label="体长" >
        </el-table-column>
        <el-table-column prop="temperature" label="温度" >
        </el-table-column>
        <el-table-column prop="humidness" label="湿度" >
        </el-table-column>
        <el-table-column  prop="name" label="监测鸟箱" >
        </el-table-column>
        <el-table-column prop="name" label="数据审核" >
        </el-table-column>
        <el-table-column prop="behavior" label="行为" >
        </el-table-column>
        <el-table-column prop="set" label="操作">
          <template slot-scope="scope">
            <i style="cursor: pointer;" @click="edit(scope.row)" class="el-icon-edit"></i>
          </template>
        </el-table-column>
      </el-table>
      <Pagination :total="pageParams.total" :currentPage="pageParams.currentPage" :pageSize="pageParams.pageSize" @handleCurrentChange="handleCurrentChange"></Pagination>
    </div>


  </div>
</template>

<script>
import Pagination from "../../../components/commons/Pagination.vue";

import { getActivePage } from '../../../api/index';

export default {
  name: 'DataManage',
  props:['basePosition'],
  components: {
    Pagination,
  },
  data() {
    return {
      searchInfo: {
        user: '',
        region: '',
        time: '',
        long: '',
        weight: '',
      },
      tableData: [
        // {  date: '2016-05-02',  name: '王小虎',  address: '上海市普陀区金沙江路 1518 弄'  }
      ],
      pageParams : {
              currentPage: 1,
              pageSize:10 ,
              total: 0
          }
    };
  },
  methods: {
    reset() {},
    onSubmit() {},
    handleCurrentChange(val) {
      this.pageParams.currentPage = val ;
      this.loadTable(this.pageParams.currentPage);
    },
    handleSelectionChange(a, b){

    },
    edit(){

    },
    loadTable(page){
      var self = this;
       //,startTime:`${currentDate} 00:00:00`,endTime:`${currentDate} 23:59:59`
      getActivePage({currentPage:page,pageSize:10,filter:{id:this.basePosition,suffix:'all'}}).then(res=>{
            console.log(res)
            if(res.status != 200){
                this.$message.error(res.data.data);
                return;
            }
            self.pageParams.currentPage = res.data.page;
            self.pageParams.total = res.data.total;
            self.pageParams.pageSize = res.data.limit;
            self.tableData = res.data.data;
        }).catch(ex=>{
            this.$message.error(ex);
        });
    }
  },
  mounted() {
    // for (let i = 0; i < 10; i++) {
    //   this.tableData.push(
    //     {  date: '2016-05-02' + i,  name: '王小虎',  address: '上海市普陀区金沙江路 1518 弄'  , set:"1" }
    //   )
    // }
    // this.pageParams.total = this.tableData.length ;
    this.loadTable();
  }
};
</script>

<style lang="scss" scoped>
.topSearch {
  margin-bottom: 20px;
  height: 76px;
  background: linear-gradient(90deg, rgba(25, 99, 135, 0.25) 0%, rgba(25, 99, 135, 0.35) 100%);
  display: flex;
  align-items: center;
  padding: 0 25px;
}

.tab {
  height: calc(100vh - 230px);
  padding: 20px;
  background: linear-gradient(90deg, rgba(25, 99, 135, 0.25) 0%, rgba(25, 99, 135, 0.35) 100%);
}
::v-deep {
  .el-form {
    display: flex;
    width: 100%;
    justify-content: space-between;
  }
  .el-form-item  {
    margin-bottom: 0;
  }
  .el-form-item__label {
    color: #fff;
    margin-right: 30px;
  }
 .s1 {
    .el-input__inner {
      width: 246px;
      height: 32px;
      background: rgba(18, 28, 38, 0.1);
      border: none;
      color: #fff;
    }
  }
  .s2 {
    .el-input__inner {
      height: 40px;
      background: rgba(18, 28, 38, 0.1);
      color: #fff;
      border: none;
    }
    .el-range-separator {
      color: #fff;
    }
    .el-range-input {
      background: none;
    }
  }
  .el-button  {
    width: 98px;
    height: 32px;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid ;
    border-image: linear-gradient(216deg, rgba(178, 255, 181, 0) 16%, rgba(178, 255, 181, 0.27) 78%) 1;
  }

  .el-table {
    overflow-y: auto;
    background: transparent;
    border: none;
  }
  .el-table::before {
    height: 0;
  }
  .el-table__header-wrapper  tr {
    height: 40px;
    background: linear-gradient(90deg, rgba(115, 255, 247, 0.208) 0%, rgba(115, 255, 247, 0.16) 100%) !important;
    .el-checkbox__inner {
      background: transparent;
      border: 1px solid rgba(115, 255, 247, 0.5);
    }
  }
  .el-table  .el-table__cell {
    background: none !important;
    height: 40px;
    color: #fff;
    font-weight: normal;
    border: none !important;
    text-align: center;
  }
  .el-table__body {
    .el-table__row {
      height: 100px;
      background: transparent;
      color: #fff;

      .el-checkbox__inner {
        background: transparent;
        border: 1px solid rgba(115, 255, 247, 0.5);
      }
    }
    .el-table__row--striped {
      background: linear-gradient(90deg, rgba(115, 255, 247, 0.078) 0%, rgba(115, 255, 247, 0.06) 100%);

    }
  }
}
</style>
